/*
 * UserConsultInfoBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-07-06
 */

package com.bjtech.domain.query;

import java.util.Date;
import com.bjtech.web.util.SelectBean;
import org.ssi.web.util.QuerySpecTpl;

/**
 * 功能概述:咨询申诉信息 <br>
 * 
 * @author 王峰
 */

public class UserConsultInfoQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private Long user_id;
	/* */
	private String title;
	/* */
	private String content_des;
	/* */
	private Long type;
	/* */
	private Long occur_num;
	/* */
	private Date consult_date;
	private Date b_consult_date;
	private Date e_consult_date;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where 1=1");

		if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(user_id)) {
				fromPart.append(" and a.user_id = ");
				fromPart.append(user_id);
			}

			if (QuerySpecTpl.isValid(title)) {
				fromPart.append(" and a.title like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(title);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(content_des)) {
				fromPart.append(" and a.content_des like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(content_des);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(type)) {
				fromPart.append(" and a.type = ");
				fromPart.append(type);
			}

			if (QuerySpecTpl.isValid(occur_num)) {
				fromPart.append(" and a.occur_num = ");
				fromPart.append(occur_num);
			}

			if (QuerySpecTpl.isValid(consult_date)) {
				fromPart
						.append(" and str_to_date(a.consult_date,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(consult_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_consult_date)) {
				fromPart
						.append(" and str_to_date(a.consult_date,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_consult_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_consult_date)) {
				fromPart
						.append(" and str_to_date(a.consult_date,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_consult_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(this.direction)
					&& QuerySpecTpl.isValid(this.sort)) {
				fromPart.append(" order by ");
				fromPart.append(this.sort);
				fromPart.append(" ");
				fromPart.append(this.direction);
			} else {
				fromPart.append(" order by ");
				fromPart.append("id");
				fromPart.append(" ");
				fromPart.append("asc");

			}
		}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUser_id() {
		return this.user_id;
	}

	public void setUser_id(Long user_id) {
		this.user_id = user_id;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent_des() {
		return this.content_des;
	}

	public void setContent_des(String content_des) {
		this.content_des = content_des;
	}

	public Long getType() {
		return this.type;
	}

	public void setType(Long type) {
		this.type = type;
	}

	public Long getOccur_num() {
		return this.occur_num;
	}

	public void setOccur_num(Long occur_num) {
		this.occur_num = occur_num;
	}

	public Date getConsult_date() {
		return this.consult_date;
	}

	public void setConsult_date(Date consult_date) {
		this.consult_date = consult_date;
	}

	public Date getB_consult_date() {
		return this.b_consult_date;
	}

	public void setB_consult_date(Date b_consult_date) {
		this.b_consult_date = b_consult_date;
	}

	public Date getE_consult_date() {
		return this.e_consult_date;
	}

	public void setE_consult_date(Date e_consult_date) {
		this.e_consult_date = e_consult_date;
	}
}
